<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-wServiceItem-add">
			<div class="form-group">
				<label class="col-sm-3 control-label">服务类型：</label>
				<div class="col-sm-8">
					<select data-placeholder="选择服务" name="serviceTypeId" id="serviceTypeId"
							class="form-control chosen-select" tabindex="2"
							style="width: 100%">
						<option value="">选择服务</option>
						<option th:value="${serviceType.typeId}" th:each="serviceType:${serviceTypeList}" th:text="${serviceType.name}">选择服务</option>
					</select>
				</div>
			</div>

			<div class="form-group">	
				<label class="col-sm-3 control-label">服务/商品名称：</label>
				<div class="col-sm-8">
					<input id="itemName" name="itemName" class="form-control" type="text">
				</div>
			</div>

			<div class="form-group">	
				<label class="col-sm-3 control-label">描述：</label>
				<div class="col-sm-8">
					<input id="spec" name="spec" class="form-control" type="text">
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">状态：</label>
				<div class="col-sm-8">
					<div class="onoffswitch">
						<input type="checkbox" th:checked="true" class="onoffswitch-checkbox" id="status" name="status" />
						<label class="onoffswitch-label" for="status">
							<span class="onoffswitch-inner"></span>
							<span class="onoffswitch-switch"></span>
						</label>
					</div>
				</div>
			</div>
		</form>
	</div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "foxwash/wServiceItem"
		$("#form-wServiceItem-add").validate({
			rules:{
				xxxx:{
					required:true,
				},
			}
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	            /*$.operate.save(prefix + "/add", $('#form-wServiceItem-add').serialize());*/
	            add();
	        }
	    }
        function  add() {
            var typeId = $("#serviceTypeId option:selected").val();
            var itemName = $("input[name='itemName']").val();
            var spec = $("input[name='spec']").val();
            var status = $("input[name='status']").is(':checked') == true ? 0 : 1;
            $.ajax({
                cache : true,
                type : "POST",
                url : prefix + "/add",
                data : {
                    "typeId": typeId,
                    "itemName": itemName,
					"spec": spec,
                    "status": status
                },
                async : false,
                error : function(request) {
                    $.modal.alertError("系统错误");
                },
                success : function(data) {
                    $.operate.successCallback(data);
                }
            });
        }
	</script>
</body>
</html>
